var html = "<div id='alert' style='background-color: rgba(0,0,0,0.5);padding: 0.5%;color: white;position: fixed;top: 45%;left: 45%;display: none;'></div>"

$(document).ready(function () {
    $('html').append(html);
});

function alertmsg(msg, state = false) {
    var msg = msg;
    var state = state;
    $('#alert').html(msg);
    $("#alert").fadeToggle("slow", function () {
        setTimeout(function () {
            $('#alert').fadeToggle('slow');
            if (state) {
                setTimeout(function () {
                    location.reload();
                }, 100)
            }
        }, 1500);

    });
}
